﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Happy.Query.Filters.Configuration
{
    /// <summary>
    /// 扩展类。
    /// </summary>
    public static class IMethodOfFilterExtentions
    {
        /// <summary>
        /// 配置筛选器。
        /// </summary>
        public static IConfigOfFilter Equal(this IMethodOfFilter that, string property, OperandType operandType, object value)
        {
            return that.Filter(property, Operator.Equal, new Operand(operandType, value));
        }

        /// <summary>
        /// 配置筛选器。
        /// </summary>
        public static IConfigOfFilter Equal(this IMethodOfFilter that, string property, object value)
        {
            return that.Equal(property, OperandType.Constant, value);
        }

        /// <summary>
        /// 配置筛选器。
        /// </summary>
        public static IConfigOfFilter NotEqual(this IMethodOfFilter that, string property, OperandType operandType, object value)
        {
            return that.Filter(property, Operator.NotEqual, new Operand(operandType, value));
        }

        /// <summary>
        /// 配置筛选器。
        /// </summary>
        public static IConfigOfFilter NotEqual(this IMethodOfFilter that, string property, object value)
        {
            return that.NotEqual(property, OperandType.Constant, value);
        }

        /// <summary>
        /// 配置筛选器。
        /// </summary>
        public static IConfigOfFilter GreaterThan(this IMethodOfFilter that, string property, OperandType operandType, object value)
        {
            return that.Filter(property, Operator.GreaterThan, new Operand(operandType, value));
        }

        /// <summary>
        /// 配置筛选器。
        /// </summary>
        public static IConfigOfFilter GreaterThan(this IMethodOfFilter that, string property, object value)
        {
            return that.GreaterThan(property, OperandType.Constant, value);
        }

        /// <summary>
        /// 配置筛选器。
        /// </summary>
        public static IConfigOfFilter LessThan(this IMethodOfFilter that, string property, OperandType operandType, object value)
        {
            return that.Filter(property, Operator.LessThan, new Operand(operandType, value));
        }

        /// <summary>
        /// 配置筛选器。
        /// </summary>
        public static IConfigOfFilter LessThan(this IMethodOfFilter that, string property, object value)
        {
            return that.LessThan(property, OperandType.Constant, value);
        }

        /// <summary>
        /// 配置筛选器。
        /// </summary>
        public static IConfigOfFilter GreaterThanOrEquals(this IMethodOfFilter that, string property, OperandType operandType, object value)
        {
            return that.Filter(property, Operator.GreaterThanOrEquals, new Operand(operandType, value));
        }

        /// <summary>
        /// 配置筛选器。
        /// </summary>
        public static IConfigOfFilter GreaterThanOrEquals(this IMethodOfFilter that, string property, object value)
        {
            return that.GreaterThanOrEquals(property, OperandType.Constant, value);
        }

        /// <summary>
        /// 配置筛选器。
        /// </summary>
        public static IConfigOfFilter LessThanOrEquals(this IMethodOfFilter that, string property, OperandType operandType, object value)
        {
            return that.Filter(property, Operator.LessThanOrEquals, new Operand(operandType, value));
        }

        /// <summary>
        /// 配置筛选器。
        /// </summary>
        public static IConfigOfFilter LessThanOrEquals(this IMethodOfFilter that, string property, object value)
        {
            return that.LessThanOrEquals(property, OperandType.Constant, value);
        }

        /// <summary>
        /// 配置筛选器。
        /// </summary>
        public static IConfigOfFilter Contains(this IMethodOfFilter that, string property, OperandType operandType, object value)
        {
            return that.Filter(property, Operator.Contains, new Operand(operandType, value));
        }

        /// <summary>
        /// 配置筛选器。
        /// </summary>
        public static IConfigOfFilter Contains(this IMethodOfFilter that, string property, object value)
        {
            return that.Contains(property, OperandType.Constant, value);
        }

        /// <summary>
        /// 配置筛选器。
        /// </summary>
        public static IConfigOfFilter NotContains(this IMethodOfFilter that, string property, OperandType operandType, object value)
        {
            return that.Filter(property, Operator.NotContains, new Operand(operandType, value));
        }

        /// <summary>
        /// 配置筛选器。
        /// </summary>
        public static IConfigOfFilter NotContains(this IMethodOfFilter that, string property, object value)
        {
            return that.NotContains(property, OperandType.Constant, value);
        }

        /// <summary>
        /// 配置筛选器。
        /// </summary>
        public static IConfigOfFilter Between(this IMethodOfFilter that, string property, OperandType leftOperandType, object leftValue, OperandType rightOperandType, object rightValue)
        {
            return that.Filter(property, Operator.Between, new Operand(leftOperandType, leftValue), new Operand(rightOperandType, rightValue));
        }

        /// <summary>
        /// 配置筛选器。
        /// </summary>
        public static IConfigOfFilter Between(this IMethodOfFilter that, string property, object leftValue, object rightValue)
        {
            return that.Between(property, OperandType.Constant, leftValue, OperandType.Constant, rightValue);
        }
    }
}
